from django.db import models

# Create your models here.
class Category(models.Model):
    name = models.CharField(max_length=20,verbose_name='类别名字')
    imgUrl=models.CharField(max_length=300,verbose_name='地址')
    class Meta:
        db_table='category'
        verbose_name_plural="商品类别"
    def __str__(self):
        return self.name
#热销商品
class HotGiids(models.Model):
    sku_name=models.CharField(max_length=50,verbose_name='热销商品名称')
    goodIntro=models.CharField(max_length=50,verbose_name='芯片')
    img=models.CharField('图片地址',max_length=300,null=False)
    sellingPrice=models.IntegerField(verbose_name='价格')
    tag=models.CharField(max_length=20,verbose_name='摄像头')
    cate = models.ForeignKey(Category, on_delete=models.CASCADE, verbose_name='商品类别')
    class Meta:
        db_table='hotGiids'
        verbose_name_plural="热销商品"
    def __str__(self):
        return self.sku_name

#新商品
class Goods(models.Model):
    sku_name=models.CharField(max_length=50,verbose_name='热销商品名称')
    good_intro=models.CharField(max_length=50,verbose_name='芯片')
    cover_img=models.CharField('图片地址',max_length=300,null=False)
    sellingPrice=models.IntegerField(verbose_name='价格')
    tag=models.CharField(max_length=20,verbose_name='摄像头')
    cate = models.ForeignKey(Category, on_delete=models.CASCADE, verbose_name='商品类别')
    class Meta:
        db_table='goods'
        verbose_name_plural="新商品"
    def __str__(self):
        return self.sku_name



class Carousel(models.Model):
    img = models.CharField("图片地址", max_length=300, null=False)
    def __str__(self):
        return '轮播图%d'%self.id

    class Meta:
        db_table = "ads"
        verbose_name = "轮播图"
        verbose_name_plural = verbose_name



class Recommends(models.Model):
    sku_name=models.CharField(max_length=50,verbose_name='热销商品名称')
    good_intro=models.CharField(max_length=50,verbose_name='芯片')
    cover_img=models.CharField('图片地址',max_length=300,null=False)
    sellingPrice=models.IntegerField(verbose_name='价格')
    tag=models.CharField(max_length=20,verbose_name='摄像头')
    cate = models.ForeignKey(Category, on_delete=models.CASCADE, verbose_name='商品类别')
    class Meta:
        db_table='recommends'
        verbose_name_plural="最新推荐"
    def __str__(self):
        return self.sku_name